﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MacViet.DataBaseAPI;

public partial class Control_Inventory_User_Inventory3 : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            load_droplist();
            int proid = Convert.ToInt32 (DDType.SelectedValue);
            load_grid(proid);
        }
    }

    public void load_droplist()
    {
        try
        {

            int accid = int.Parse(Session["ACC_ID"].ToString());
            //Session["ACC_ID"];
            PRODUCT_TYPESDataAPI product_type = new PRODUCT_TYPESDataAPI();
            DataTable dt_protype = product_type.GetPRO_TYPE_NAME_ACCID(accid);

            DDType.DataSource = dt_protype; //set DataSource property of DropDownList

            DDType.DataTextField = dt_protype.Columns[1].ToString(); //set DataTextField to first column(countryColumn) of dt

            DDType.DataValueField = dt_protype.Columns[0].ToString(); //set DataTextField to second column (capitalColumn) of dt

            DDType.DataBind(); //bind data to DropDownList


        }
        catch (Exception ex)
        {

            ex.ToString();
        }
   
    
    }
    public void load_grid(int proid)
    {

        //try
        //{
        //    int accid = int.Parse(Session["ACC_ID"].ToString());
        //    PRODUCTSDataAPI product = new PRODUCTSDataAPI();
        //    DataTable dt = product.getByPRO_QTTY_INVENTORY(proid, accid);
        //    if (dt != null)
        //    {
        //        GVproduct.DataSource = dt;
        //        GVproduct.DataBind();

        //    }
        //    else 
        //    {
      
        //        GVproduct.DataSource = dt;
        //        GVproduct.DataBind();
        //    }
        //}
        //catch (Exception ex)
        //{

        //    ex.ToString();
        //}
    }


    protected void DDType_TextChanged(object sender, EventArgs e)
    {
        int proid = Convert.ToInt32(DDType.SelectedValue);
        load_grid(proid);
    }
}

